The Soda Pop


Login Function In ASP window Form C#

private void button5_Click(object sender,EventArgs e)

{

SqlConnection conn =new SqlConnection();

conn.ConnectionString =@"Data Source=.\SQLEXPRESS;­AttachDbFilename=C:\­Users\ASIF\Documents­\Visual Studio2010\Projects\connec­tion\connection\cone­ctionDB.mdf;Integrated Security=True;User Instance=True";

conn.Open();

string qry1 = "Select *from Table1 WHERE pass = @pass";


SqlCommand comand =
new SqlCommand(qry1,conn);


­comand.Parameters.Ad­dWithValue("@pass",this.textBox1.Text);


SqlDataReader sdr =comand.ExecuteReader();


while (sdr.Read())

{

if (sdr.HasRows == true)

{

MessageBox.Show("login Successfull ");

}

}

if (sdr.HasRows ==false)

{

­MessageBox.Show("Access Denied ");

}